package com.neusoft.demo11;

import java.io.*;

public class Test2 {
    public static void main(String[] args) {
        try {
            //源文件
            FileReader fileReader = new FileReader("Test2.java");
            BufferedReader br = new BufferedReader(fileReader);
            //目标文件
            FileWriter fileWriter = new FileWriter("NewTest2.java");
            BufferedWriter bw = new BufferedWriter(fileWriter);
            //读取一个文本行
            String str = br.readLine();
            while (br.readLine() != null) {
                bw.write(str);
                //换行
                bw.newLine();
                str = br.readLine();
            }
            br.close();
            bw.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
